$(function(){
//判断是否登入
	decidelongin();
	//往期回顾
	$('#dropmenu > li').bind('mouseover', dropmenu_open);
	$('#dropmenu > li').bind('mouseout',  dropmenu_timer);
//导航条 
		$(".nav").movebg({
			width : 100/*滑块的大小*/,
			extra : 40/*额外反弹的距离*/,
			speed : 300/*滑块移动的速度*/,
			rebound_speed : 400
		/*滑块反弹的速度*/
		});
		//浮动搜索框拖动js
		var mFlag=false;
	//鼠标与div左上角相对位置
		var divX='',divY='',
			pl=$(".v-play");
		pl.bind("click mousedown", function(e){
			e= e || window.event;
		if (e.type == 'click') {
			}else if(e.type == 'mousedown') {
			mFlag=true;
			divX =e.pageX - parseInt(pl.css("left"));
			divY =e.pageY - parseInt(pl.css("top"));
			}
		});
		$(document).mousemove(function(e){
			if(mFlag){
		//画出新坐标
			var pl=$(".v-play");
				le = e.pageX-divX,
				to = e.pageY-divY,
				winH = $(window).height(),
				winW = $(window).width(),
				cW = winW-pl.width()-20,
				cH = winH-pl.height()-20;
			if(le<0){
				le=0;
				}else if(le>cW){
					le=cW;
					}
			if(to<0){
				to=0;
				}else if(to>cH){
				to =cH;
				}
			pl.css({top:to,left:le});
			}
		}).mouseup(function(){
			mFlag=false;
		
			}); 	
});


/*var content="<form name='userlogin' action='/result/headLogin.do' method='POST'>"+
				"<div class='fb'>"+
					"<span>用户名</span> "+
					"<input name='username' style='width: 162px' class='ipt-txt' type='text'> "+
					"<a href='/skip/register.do'>注册帐号</a>"+
				"</div>"+
				"<div class='fb' style='margin-top: 5px;'>"+
					"<span>密&nbsp;&nbsp;码</span> "+
					"<input name='password' style='width: 100px' class='ipt-txt' type='password'>"+
					"<button type='submit' class='btn-1' style='margin-left:6px'>登录</button>"+
					"<a href='/skip/forgetPwd.do' style='margin-left:6px'>忘记密码?</a>"+
				"</div>"+
			"</form>";*/
	function contenter(date,time){
		return "<div id='loginDiv' class='vip'>"+
		      "<ul style='margin-top: 10px'>"+
					"<li class='n'><span id='greetings'>"+time+"</span>"+ 
					" <a href='http://www.100tk.com/user/' class='userName'>["+date+"]</a>"+
						"<span style='padding-left: 20px'> "+
						    "<a href='/skip/afterLogin/alterPassword.do'>修改密码</a>"+
							"<a href='/result/dologout.do'>[安全退出]</a>"+
					"</span></li>"+
					"<li class='m'>"+
					   " <a href='/skip/afterLogin/afLoCollect.do' style='margin-right:5px'>[收藏图]</a>"+
						"<a href='/skip/afterLogin/afLoCollect.do?type=1' style='margin-right:5px'>[彩色图]</a>"+
						"<a href='/skip/afterLogin/afLoCollect.do?type=2' style='margin-right:5px'>[黑白图]</a>"+
						"<a style='padding-right: 0px' href='/bcDraw/afterLogin/afLoCollect.do'>[全年图纸]</a>"+
					"</li>"+
					"</ul>"+
				"</div>";
	}		
//判断是否登入
function decidelongin(){
	var times=time();
	$.ajax({
		type:"post", //提交的类型
		url:"/skip/checkoutLogin.do",//提交地址
		dataType: 'text',
		success: function(data){ //回调方法
			if(""!=data)
			$("#loginDiv").replaceWith(contenter(data,times)); 
				/*if(""==data){
					$("#loginDiv").append(content); 
				}else{
					$("#loginDiv").append(contenter(data,times)); 
				}*/
		}
   });
}
function time(){
	/*时间  */
	now = new Date(), hour = now.getHours();
	if (hour < 6) {
	    return "凌晨好！";		
	} else if (hour < 9) {
	    return "早上好！";		
	} else if (hour < 12) {
	    return "上午好！";
	} else if (hour < 14) {
	    return "中午好！";
	} else if (hour < 17) {
	    return "下午好！";
	} else if (hour < 19) {
	     return "傍晚好！";
	} else if (hour < 22) {
	    return "晚上好！";
	} else {
	    return "深里好！";
	}
}


//往期回顾的js
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function dropmenu_open()
{	dropmenu_canceltimer();
	dropmenu_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function dropmenu_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function dropmenu_timer()
{	closetimer = window.setTimeout(dropmenu_close, timeout);}

function dropmenu_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}

document.onclick = dropmenu_close;


//加入收藏
	function AddFavorite(url, title) {
		 if(confirm("网站名称："+title+"\n网址："+url+"\n确定添加收藏?")){
		        var ua = navigator.userAgent.toLowerCase();
		        if(ua.indexOf("msie 8")>-1){
		            external.AddToFavoritesBar(url,title,'');//IE8
		        }else{
		            try {
		                window.external.addFavorite(url, title);
		            } catch(e) {
		                try {
		                    window.sidebar.addPanel(title, url, "");//firefox
		                } catch(e) {
		                    alert("加入收藏失败，请使用Ctrl+D进行添加");
		                }
		            }
		        }
		    }
		    return false;
	}
	//页面顶左侧时间
	function getCurDate()
	{
	 var d = new Date();
	 var week;
	 switch (d.getDay()){
	 case 1: week="星期一"; break;
	 case 2: week="星期二"; break;
	 case 3: week="星期三"; break;
	 case 4: week="星期四"; break;
	 case 5: week="星期五"; break;
	 case 6: week="星期六"; break;
	 default: week="星期天";
	 }
	 var years = d.getFullYear();
	 var month = add_zero(d.getMonth()+1);
	 var days = add_zero(d.getDate());
	 var hours = add_zero(d.getHours());
	 var minutes = add_zero(d.getMinutes());
	 var seconds=add_zero(d.getSeconds());
	 var ndate = years+"年"+month+"月"+days+"日 "+hours+":"+minutes+":"+seconds+" "+week;
	 var divT=document.getElementById("divT"); 
	 divT.innerHTML= ndate;
	}
	 
	function add_zero(temp)
	{
	 if(temp<10) return "0"+temp;
	 else return temp;
	}
	setInterval("getCurDate()",100);	
	
	
	//浮动搜索款页面距离
	$(window).scroll(function(){
		if($(this).scrollTop()>400){
			/* view_console(0);//隐藏控制器和列表 */
			$(".v-play").addClass("miniplayer");//先加个class让他缩小放到右下角
			}else{
				$(".v-play").removeClass("miniplayer");
				/* view_console(1);//显示控制器和列表 */
	        }				
		});
	
	